home *** CD-ROM | disk | FTP | other *** search
- title TIMERR02 -- Read High Resolution Timer Information
- page 60,120
-
- name TIMERR02 ; module
-
- comment | Module Specifications
-
- Copyright: None.
-
- Environment: IBM PC, tested under DOS 2.0.
-
- Segmentation: Program segment CODE, public, byte aligned, class ''.
-
- Public symbols and external references: See Symbols section of listing.
-
- Link requirements: None, standalone subroutine.
-
- Program derived from: None.
-
- Original code by: Bob Smith and Tom Puckett, October 1983.
-
- Modifications by: None.
-
-
- Procedure Specifications
-
- Public Procedure TIMERR02 -- High Resolution Timer Read Routine
-
- This is a subroutine to return high resolution timing information
- obtained from the BIOS TIMER_LOW and TIMER_HIGH fields, extended
- with low order information obtained from the current residual count
- of Counter 0 of the 8253. (See routine TIMERS01 for initializing
- Counter 0.)
-
- Assumptions: Counter 0 running in Mode 2, with full count of 65536.
- Locations of BIOS TIMER_LOW and TIMER_HIGH fields are
- 40:6C and 40:6E respectively.
-
- Linkage: Near call and return.
-
- Arguments: None.
-
- Effects: None.
-
- Results: Flags destroyed.
- AX = TIMER_HIGH.
- BX = TIMER_LOW.
- CX = low order extension obtained by reading 8253.
-
- Return conditions: None.
-
- Limitations: None.
-
- |
- page
-
- bios_data_seg equ 40h
- bios_data segment at 40h
- org 6ch
- timer_low dw ?
- timer_high dw ?
- bios_data ends
-
- code segment public byte
- assume cs:code
-
- ; equates....
-
- timer_0 equ 40h ; 8253 channel 0 port
- timer_ctl equ 43h ; 8253 control port
-
- timer_0_latch equ 00h ; 8253 command to save channel 0 current count
-
-
- public TIMERR02
- TIMERR02 proc near ; see specifications at head of listing
-
- push ds
- mov ax,bios_data_seg ; get pointer to BIOS data area
- mov ds,ax
- assume ds:bios_data
-
- mov al,timer_0_latch ; timer 0, latch
-
- cli ; hold off interrupts while fetching data
- out timer_ctl,al ; latch current count in 8253
- mov bx,timer_low ; get matching values...
- mov cx,timer_high
- in al,timer_0 ; read in low order byte
- mov ah,al ; tuck it out of the way
- nop ; insure 5 clocks for 8253 recovery time
- in al,timer_0 ; read in high order byte
- sti ; allow interrupts again
-
- xchg ah,al ; get in right order in register
- neg ax ; get up count from down
- xchg ax,cx ; return in common register order
- pop ds ; restore
- ret
-
- TIMERR02 endp
-
- code ends ; end code segment
-
- end ; end module